using System;
using Microsoft.Xna.Framework;
using Xfinity.Entities.Managers;

namespace Xfinity.Actors
{
    public class PlayerManager : GlobalManager
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerManager"/> class.
        /// </summary>
        /// <param name="playerName">Name of the player.</param>
        /// <param name="game">The game.</param>
        public PlayerManager(string playerName, Game game)
            : base(
            (String.IsNullOrEmpty(playerName) ?
            Xfinity.Settings.EngineSettings.PlayerName
            : playerName
            ) + " Manager", false, game)
        {

            if (String.IsNullOrEmpty(playerName))
            {
                playerName = Xfinity.Settings.EngineSettings.PlayerName;
            }
            if (String.IsNullOrEmpty(Xfinity.Settings.EngineSettings.PlayerName) && String.IsNullOrEmpty(playerName))
            {
                Xfinity.Settings.EngineSettings.PlayerName = Environment.UserName;
                Xfinity.Settings.EngineSettings.Save();
                playerName = Xfinity.Settings.EngineSettings.PlayerName;
            }


            player = new Player(playerName, game);
        }
        /// <summary>
        /// Gets the name of the player.
        /// </summary>
        /// <value>The name of the player.</value>
        public string PlayerName
        {
            get { return player.Name; }
        }
        private Player player;

        /// <summary>
        /// Gets the player.
        /// </summary>
        /// <value>The player.</value>
        public Player Player
        {
            get { return player; }
        }

    }
}
